<?php
//=======================================
// !! GYSN RELEASE - DO NOT REMOVE  !!
// !! DeZend by: syairx             !!
// !! Debug by: syairx & str/GYSN   !!
// !! Nullify by: str/GYSN & syairx !!
// !! GYSN RELEASE - DO NOT REMOVE  !!
//=======================================

if ( !file_exists( dirname( __FILE__ )."/index.php" ) )
{
	echo "<font face='Verdana, Arial, Helvetica' size='2' color='red'>Please upload the index.php from the setup directory of package to use the setup system</font>";
	exit;
}

define( "SETUPTYPE", "Setup" );
define( "INTERFACETYPE", "WEB" );

if ( defined( "SWIFTCUSTOMPATH" ) )
{
	chdir( SWIFTCUSTOMPATH );
}
else
{
	chdir( './../' );
}

set_magic_quotes_runtime( 0 );
ini_set( 'session.use_trans_sid', false );
ini_set( 'session.bug_compat_42', true );

error_reporting( E_ALL & ~E_NOTICE );

require_once( "./includes/functions.php" );
require_once( "./setup/includes/functions.php" );
$_SETUP["modules"] = getSetupModules( );
require_once( "./config/config.php" );
require_once( "./includes/SmartyLight/class.template.php" );
require_once( "./locale/".cleanVar( $_SWIFT["adminlanguage"] )."/setup.php" );
$dbCore = new dbCore( $_DB["hostname"], $_DB["username"], $_DB["password"], $_DB["name"], $_DB["type"], true, $_DB["port"] );
$registry = new Registry;
$datastore = new DataStore;
$cookie = new Cookie;

$_SWIFT["steps"] = array(
0 => "License Agreement",
1 => "Verify Database",
2 => "Enter Info",
3 => "Auto Setup",
4 => "Settings",
5 => "Templates",
6 => "Languages",
7 => "Finish"
);

if ( !isset( $_POST["step"] ) )
{
	$_POST["step"] = 0;
}

if ( $_POST["step"] == "1")
{
	if ( $_POST["submitbutton"] == "Continue"  )
	{
		$_POST["step"] = "2";
	}
}

if ( $_POST["step"] == "7" )
{
	require_once( dirname( __FILE__ )."/steps/setup_step7.php" );
}

if ( $_POST["step"] == "6" )
{
	require_once( dirname( __FILE__ )."/steps/setup_step6.php" );
}

if ( $_POST["step"] == "5" )
{
	require_once( dirname( __FILE__ )."/steps/setup_step5.php" );
}

if ( $_POST["step"] == "4" )
{
	require_once( dirname( __FILE__ )."/steps/setup_step4.php" );
}

if ( $_POST["step"] == "3" )
{
	if ( $_POST["password"] != $_POST["password2"] )
	{
		$_POST["step"] = "2";
		$_SWIFT["error"] = true;
		$_SWIFT["errormsg"] = "Password do not match";
	}
	else if ( trim( $_POST["producturl"] ) == "" || trim( $_POST["companyname"] ) == "" || trim( $_POST["password"] ) == "" || trim( $_POST["fullname"] ) == "" || trim( $_POST["email"] ) == "" )
	{
		$_POST["step"] = "2";
		$_SWIFT["error"] = true;
		$_SWIFT["errormsg"] = "One of the required field(s) is empty";
	}
	else
	{
		require_once( dirname( __FILE__ )."/steps/setup_step3.php" );
	}
}

if ( $_POST["step"] == "2" )
{
	require_once( dirname( __FILE__ )."/steps/setup_step2.php" );
}

if ( $_POST["step"] == "1" )
{
	require_once( dirname( __FILE__ )."/steps/setup_step1.php" );
}

if ( $_POST["step"] == "0" )
{
	require_once( dirname( __FILE__ )."/steps/setup_step0.php" );
}
?>